package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.shop.pojo.Merchant;
import com.example.shop.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MerchantMapper extends BaseMapper<Merchant> {


    @Insert("insert into merchant(merchant_id,merchant_avatar,merchant_name,merchant_introduction," +
            "merchant_longitude,merchant_latitude,merchant_area,merchant_detailed_address,merchant_phone," +
            "merchant_quality_grade,merchant_account,merchant_password,merchant_state,merchant_register_date," +
            "merchant_resource_dir) " +
            "values(#{et.merchantId},#{et.merchantAvatar},#{et.merchantName},#{et.merchantIntroduction}," +
            "${et.merchantLongitude},${et.merchantLatitude},#{et.merchantArea},#{et.merchantDetailedAddress},#{et.merchantPhone}," +
            "${et.merchantQualityGrade},#{et.merchantAccount},#{et.merchantPassword},${et.merchantState},#{et.merchantRegisterDate}," +
            "#{et.merchantResourceDir})")
    int insert(@Param(Constants.ENTITY) Merchant merchant);

    @Update("update merchant set ${dbFiled} = #{value} where merchant_id = #{id}")
    int updateFieldById(@Param("id") long id, @Param("dbFiled") String dbFiled, @Param("value") Object value);
}
